package org.shana.shortlink.admin.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.shana.shortlink.admin.common.convention.result.Result;
import org.shana.shortlink.admin.remote.ShortLinkRemoteService;
import org.shana.shortlink.admin.remote.dto.req.ShortLinkStatsReqDTO;
import org.shana.shortlink.admin.remote.dto.resp.ShortLinkStatsAccessRecordRespDTO;
import org.shana.shortlink.admin.remote.dto.resp.ShortLinkStatsRespDTO;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 短链接监控控制层
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("api/v1/short-link/admin/stats")
public class ShortLinkStatsController {

    /**
     * 后续重构为 SpringCloud Feign 调用
     */
    ShortLinkRemoteService shortLinkRemoteService = new ShortLinkRemoteService() {
    };

    /**
     * 访问单个短链接指定时间内监控数据
     */
    @GetMapping
    public Result<ShortLinkStatsRespDTO> shortLinkStats(ShortLinkStatsReqDTO requestParam) {
        return shortLinkRemoteService.oneShortLinkStats(requestParam);
    }

//
//    /**
//     * 访问分组短链接指定时间内监控数据
//     */
//    @GetMapping("/group")
//    public Result<ShortLinkStatsRespDTO> groupShortLinkStats(ShortLinkGroupStatsReqDTO requestParam) {
//        return shortLinkRemoteService.groupShortLinkStats(
//                requestParam.getGid(),
//                requestParam.getStartDate(),
//                requestParam.getEndDate()
//        );
//    }
//
    /**
     * 访问单个短链接指定时间内访问记录监控数据
     */
    @GetMapping("access-record")
    public Result<Page<ShortLinkStatsAccessRecordRespDTO>> shortLinkStatsAccessRecord(ShortLinkStatsReqDTO requestParam) {
        return shortLinkRemoteService.shortLinkStatsAccessRecord(requestParam);
    }

    /**
     * 访问分组短链接指定时间内访问记录监控数据
     */
//    @GetMapping("/access-record/group")
//    public Result<Page<ShortLinkStatsAccessRecordRespDTO>> groupShortLinkStatsAccessRecord(ShortLinkGroupStatsAccessRecordReqDTO requestParam) {
//        return shortLinkRemoteService.groupShortLinkStatsAccessRecord(
//                requestParam.getGid(),
//                requestParam.getStartDate(),
//                requestParam.getEndDate(),
//                requestParam.getCurrent(),
//                requestParam.getSize()
//        );
//    }
}
